import serial.tools.list_ports

ports = list(serial.tools.list_ports.comports())
print("检测到", len(ports), "个串口:")
for port in ports:
    print(f"  {port.device}: {port.description}")
